package com.youku.plugins.commonui.view.noticeCard
{
   import flash.text.TextField;
   import com.youku.utils.AssetUtil;
   import com.youku.plugins.commonui.CommonUIFont;
   import com.youku.plugins.commonui.CommonUIConstant;
   import flash.events.TextEvent;
   import com.youku.plugins.commonui.CommonUIEvent;
   
   public class ErrorCard extends BaseNoticeCard
   {
      
      public function ErrorCard() {
         super();
         this.init();
      }
      
      protected var _errorText:TextField;
      
      override protected function init() : void {
         super.init();
         this._errorText = AssetUtil.getTextField(true);
         this._errorText.defaultTextFormat = CommonUIFont.FONT_NOTICE_TEXT_CENTER;
         this._errorText.width = CommonUIConstant.NOTICE_CARD_WIDTH;
         this._errorText.height = 140;
         this._errorText.text = "";
         _card.addChild(this._errorText);
         this._errorText.addEventListener(TextEvent.LINK,this.onLinkEvent);
      }
      
      private function onLinkEvent(param1:TextEvent) : void {
         switch(param1.text)
         {
            case "refresh":
               dispatchEvent(new CommonUIEvent(CommonUIEvent.NOTICE_REFRESH));
               break;
            case "report":
               dispatchEvent(new CommonUIEvent(CommonUIEvent.NOTICE_BUG_REPORT,_errorCode));
               break;
            case "getflash":
               dispatchEvent(new CommonUIEvent(CommonUIEvent.NOTICE_GET_FLASH));
               break;
         }
      }
      
      override protected function updateLayout() : void {
         super.updateLayout();
         _noticeIcon.y = 60;
         this._errorText.x = 0;
         this._errorText.y = _noticeIcon.y + _noticeIcon.height + 35;
      }
      
      override public function setSize(param1:Number, param2:Number) : void {
         super.setSize(param1,param2);
         this._errorText.width = CommonUIConstant.NOTICE_CARD_WIDTH;
         this._errorText.height = 140;
         this.updateLayout();
      }
      
      override public function setText(param1:String) : void {
         this._errorText.htmlText = param1;
      }
   }
}
